package com.elinkway.infinitemovies.selfdata;

import com.elinkway.infinitemovies.application.MoviesApplication;
import com.elinkway.infinitemovies.bigdata.BigDataConstants;
import com.elinkway.infinitemovies.bigdata.BigDataUtils;
import com.elinkway.infinitemovies.bigdata.RealDataConfig;
import com.elinkway.infinitemovies.dao.PreferencesManager;
import com.elinkway.infinitemovies.selfdata.bean.MyDataRecord;
import com.elinkway.infinitemovies.utils.MoviesUtils;

/**
 * Author: liuxiaojiang(xiao)
 * Date: 2017-07-10
 * Time: 15:39
 * Description: FIXME
 */
public class MyDataRecordCreater {
    public static <T extends MyDataRecord> T build(Class<T > a){
        T record = null;
        try {
            record = a.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        record.setSarrs(RealDataConfig.getSarrs());
        record.setOs("0");
        record.setDevice(MoviesUtils.getDeviceModel());
        record.setChannel(MoviesUtils.getClientChannel());
        record.setAuid(BigDataConstants.AUID);
        record.setImei(BigDataConstants.IMEI);
        record.setMac(BigDataConstants.MAC);
        record.setVersion(MoviesUtils.getClientVersionName());
        record.setIlu(BigDataUtils.isLoginUser());
        record.setNt(BigDataUtils.getNetType(MoviesApplication.getInstance()));
        record.setCtime(System.currentTimeMillis() + "");
        record.setTags(PreferencesManager.getInstance().getTags());
        return record;
    }
}
